**# Bookmark #1 Setting

*Windows
global root  = "G:/Dropbox/Environmental Injustice/Empirical"
global rawdata = "$root/rawdata"
global workdata = "$root/workdata"
global results = "$root/results"
global outfile = "$root/outfile"

cd "$workdata"

**# Bookmark #2 Table S3
use "$outfile/Table S3.dta",clear

matrix T = J(8, 3, .)

*Share of Below High School
ttest city_target,by(belowhs_median)

local belowhs0_mean = r(mu_1)
local belowhs1_mean = r(mu_2)
local belowhsdiff_mean = r(mu_1) - r(mu_2)

local belowhs0_se = r(sd_1)/sqrt(r(N_1))
local belowhs1_se = r(sd_2)/sqrt(r(N_2))
local belowhsdiff_se = r(se)

matrix T[1,1] = `belowhs0_mean'
matrix T[1,2] = `belowhs1_mean'
matrix T[1,3] = `belowhsdiff_mean'

matrix T[2,1] = `belowhs0_se'
matrix T[2,2] = `belowhs1_se'
matrix T[2,3] = `belowhsdiff_se'

*Share of Below College
ttest city_target,by(belowcl_median)

local belowcl0_mean = r(mu_1)
local belowcl1_mean = r(mu_2)
local belowcldiff_mean = r(mu_1) - r(mu_2)

local belowcl0_se = r(sd_1)/sqrt(r(N_1))
local belowcl1_se = r(sd_2)/sqrt(r(N_2))
local belowcldiff_se = r(se)

matrix T[3,1] = `belowcl0_mean'
matrix T[3,2] = `belowcl1_mean'
matrix T[3,3] = `belowcldiff_mean'

matrix T[4,1] = `belowcl0_se'
matrix T[4,2] = `belowcl1_se'
matrix T[4,3] = `belowcldiff_se'

*Share of Rural Hukou Holders
ttest city_target,by(rural_median)

local rural0_mean = r(mu_1)
local rural1_mean = r(mu_2)
local ruraldiff_mean = r(mu_1) - r(mu_2)

local rural0_se = r(sd_1)/sqrt(r(N_1))
local rural1_se = r(sd_2)/sqrt(r(N_2))
local ruraldiff_se = r(se)

matrix T[5,1] = `rural0_mean'
matrix T[5,2] = `rural1_mean'
matrix T[5,3] = `ruraldiff_mean'

matrix T[6,1] = `rural0_se'
matrix T[6,2] = `rural1_se'
matrix T[6,3] = `ruraldiff_se'

*Share of Skilled Occupation Workers
ttest city_target,by(occupation_median)

local occupation0_mean = r(mu_1)
local occupation1_mean = r(mu_2)
local occupationdiff_mean = r(mu_1) - r(mu_2)

local occupation0_se = r(sd_1)/sqrt(r(N_1))
local occupation1_se = r(sd_2)/sqrt(r(N_2))
local occupationdiff_se = r(se)

matrix T[7,1] = `occupation0_mean'
matrix T[7,2] = `occupation1_mean'
matrix T[7,3] = `occupationdiff_mean'

matrix T[8,1] = `occupation0_se'
matrix T[8,2] = `occupation1_se'
matrix T[8,3] = `occupationdiff_se'

matrix list T
svmat T, names(col)
keep c1 c2 c3
drop if c1==.
format c1 c2 c3 %9.3f

gen indicator = ""
replace indicator = "Share of Below High School" in 1
replace indicator = "(Standard Error)" in 2
replace indicator = "Share of Below College" in 3
replace indicator = "(Standard Error)" in 4
replace indicator = "Share of Rural Hukou Holders" in 5
replace indicator = "(Standard Error)" in 6
replace indicator = "Share of Skilled Occupation Workers" in 7
replace indicator = "(Standard Error)" in 8